﻿//calculates value of determinant n*n and inverse matrix

using System;

namespace mat_det03
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            Matrix mat03 = new Matrix(new[,]
        {
            {1.0f, 2.0f, -1.0f},
            {-2.0f, -5.0f, -1.0f},
            {1.0f, -1.0f, -2.0f},
        });

            Matrix mat04 = new Matrix(new[,]
        {
            {1.0f, 2.0f, 1.0f, 3.0f},
            {-2.0f, -5.0f, -2.0f, 1.0f},
            {1.0f, -1.0f, -3.0f, 2.0f},
            {4.0f, -1.0f, -3.0f, 1.0f},
        });

            Matrix mat05 = new Matrix(new[,]
        {
            {1.0f, 2.0f, 1.0f, 2.0f, 3.0f},
            {2.0f, 1.0f, 2.0f, 2.0f, 1.0f},
            {3.0f, 1.0f, 3.0f, 1.0f, 2.0f},
            {1.0f, 2.0f, 4.0f, 3.0f, 2.0f},
            {2.0f, 2.0f, 1.0f, 2.0f, 1.0f},
        });

            float[,] inverse;


            //DisplayMatrix.displayMatrix(mat03);
            double determinant = mat03.MatrixDeterminant();
            Console.WriteLine("determinant is: {0}", determinant);

            inverse = mat03.MatrixInverse();


            determinant = mat04.MatrixDeterminant();
            Console.WriteLine("determinant is: {0}", determinant);

            inverse = mat04.MatrixInverse();



            determinant = mat05.MatrixDeterminant();
            Console.WriteLine("determinant is: {0}", determinant);

            inverse = mat05.MatrixInverse();

            DisplayMatrix.displayMatrix(inverse);

            //for (int i = 0; i < inverse.GetLength(0); i++)
            //{
            //    for (int j = 0; j < inverse.GetLength(1); j++)
            //    {
            //        Console.Write("{0}  ", inverse[i, j]);
            //    }
            //    Console.WriteLine();
            //};

            //Console.WriteLine("Inverse of m computed from its decomposition is\n" + MatrixAsString(inverse));
        }
    }
}